//--------------------------------------------------------------
//
// Qizhi Zhang 
// ezhung@gmail.com
// http://www.moorwind.com
//
//--------------------------------------------------------------
package reader.model.vo
{
	import __AS3__.vec.Vector;
	
	import mx.formatters.DateFormatter;
	
	public class BlogDraftVO extends SelectAbleVO
	{
		public static const BLOG_DRAFT_ALIAS:String = "reader.model.vo.BlogDraftVO";
		
		private var _draftId:int = -1;
		public function get draftId():int
		{
			
			return _draftId;
		}
		public function set draftId(value:int):void
		{
			_draftId = value;
		}
		
		private var _title:String;
		public function get title():String
		{
			
			return _title
		}
		public function set title(value:String):void
		{
			_title = value;
		}
		
		private var _description:String;
		public function get description():String
		{
			
			return _description;
		}
		public function set description(value:String):void
		{
			_description = value;
		}
			
		//published
		
		private var _pubDate:Date;
		public function get pubDate():Date
		{
			
			return _pubDate;
		}
		public function set pubDate(value:Date):void
		{
			_pubDate = value;
		}
		
		private var _creatDate:Date;
		public function get creatDate():Date
		{
			
			return _creatDate;
		}
		public function set creatDate(value:Date):void
		{
			_creatDate = value;
		}
		
		private var _updateDate:Date;
		public function get updateDate():Date
		{
			
			return _updateDate;
		}
		public function set updateDate(value:Date):void
		{
			_updateDate = value;
		}

		private var _platforms:String;
		public function get platforms():String
		{
			
			return _platforms;
		}
		public function set platforms(value:String):void
		{
			_platforms = value;
		}
		
		private var _platformid:int = -1;
		public function get platformid():int
		{
			
			return _platformid;
		}
		public function set platformid(value:int):void
		{
			_platformid = value;
		}
		
		private var _isPubed:Boolean;
		public function get isPubed():Boolean
		{
			
			return _isPubed;
		}
		public function set isPubed(value:Boolean):void
		{
			_isPubed = value;
		}
		
		private var _deleteAble:Boolean = true;
		public function get deleteAble():Boolean
		{
			
			return _deleteAble;
		}
		public function set deleteAble(value:Boolean):void
		{
			_deleteAble = value;
		}
		
		private var _editAble:Boolean = true;
		public function get editAble():Boolean
		{
			
			return _editAble;
		}
		public function set editAble(value:Boolean):void
		{
			_editAble = value;
		}
		
		private var _link:String;
		public function get link():String
		{
			
			return _link;
		}
		public function set link(value:String):void
		{
			_link = value;
		}
		
		private var _postid:String;
		public function get postid():String
		{
			
			return _postid;
		}
		public function set postid(value:String):void
		{
			_postid = value;
		}
		
		public function get date():String
		{
			return isPubed ? pubdate : createdate;
		}
		
		public function get pubdate():String
		{
			return isPubed ? formatDate(pubDate):"";
		}
		public function get pubTime():Number
		{
			return isPubed ? pubDate.getTime() : 0;
		}
		
		public function get createdate():String
		{
			return formatDate(creatDate);
		}
		public function get createTime():Number
		{
			return creatDate.getTime();
		}
		
		private static function formatDate(date:Date):String
		{
			var format:DateFormatter = new DateFormatter();
			format.formatString = "YYYY/MM/DD HH:NN";
			return format.format(date);
		}
		
		public static function formatDraftDate(date:Date):String
		{
			var format:DateFormatter = new DateFormatter();
			format.formatString = " YY/M/D,H:N:S";
			return format.format(date);
		}
		
		//----------------------------------------------------------------------------
		//
		// Convert Vector to Array
		//
		//----------------------------------------------------------------------------
		
		public static function VectorToArray(v:Vector.<BlogDraftVO>):Array/* of BlogDraftVO */
		{
			var a:Array = [];
			for each(var i:BlogDraftVO in v)
			{
				a.push(i);
			}
			return a;
		}
		
		public static function ArrayToVector(a:Array/* of BlogDraftVO */):Vector.<BlogDraftVO>
		{
			var v:Vector.<BlogDraftVO> = new Vector.<BlogDraftVO>();
			for each(var i:BlogDraftVO in a)
			{
				v.push(i);
			}
			return v;
		}
	}
}